import React from 'react';
import ReactDOM from 'react-dom';
import MyInput from './components/MyInput'
/* 
  受控组件：表单的内容受组件的数据控制 这类表单称为受控组件
  非受控组件：

*/
class App extends React.Component {
  state = {
    name: "珠峰"
  }
  render() {
    let { name } = this.state;
    return <div className=''>
      <h1>{name}</h1>
      <input type="text" onInput={e => { }} />
      <input type="text" value={name} onChange={e => { this.setState({ name: e.target.value }) }} />
      <MyInput
        type="text"
        value={name}
        placeholder='hahaha'
        onChange={e => { this.setState({ name: e.target.value }) }}
        onPressEnter={() => { console.log('回车') }} />
    </div>;
  }
}

ReactDOM.render(<App />, document.getElementById('root'))